package com.example.bbs.web.servlet; /**
 * @auther: zhangxin
 * @Description:
 */

import com.example.bbs.service.ReplyService;
import com.example.bbs.service.impl.ReplyServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "DeleteServlet", value = "/bbs/delete")
public class DeleteServlet extends HttpServlet {

    ReplyService replyService = new ReplyServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
          req.setCharacterEncoding("UTF-8");
          int replyId = Integer.parseInt(req.getParameter("replyId"));
          int postId = Integer.parseInt(req.getParameter("postId"));
          boolean bool = replyService.deleteReplyByReplyId(replyId,postId);
          if(bool){
             resp.sendRedirect("/bbs/postDetail?pid=" + postId);
         }
    }

}
